package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: tao
 * Date: 2023-11-23
 * Time: 11:08
 */
public class ThreadDemo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
           for (int i = 0; i < 5; i++) {
               System.out.println("我是一个线程，正在工作");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
            System.out.println("线程结束");
        });
        t.start();
        t.join();
        System.out.println("这时一个主线程，在t线程结束后再执行");
    }
}
